1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
---
import Button from '$components/Button.astro';
import CommitteeList from '$components/CommitteeList/CommitteeList.astro';
import NewsIndex from '$components/NewsIndex/NewsIndex.astro';
import translate from '$i18n/translate';
import tPage from '$i18n/translations/pages/home';
import Page from '$layouts/Page.astro';
import localeStaticPaths from '$lib/localeStaticPaths';
import { isBefore, isNewsItemInLocale } from '$lib/newsUtils';
import type Locale from '$types/Locale';
import { getCollection } from 'astro:content';
export async function getStaticPaths() {
return localeStaticPaths;
}
const locale = Astro.params.locale as Locale;
const t = translate(locale);
const allNewsItemsInLocale = await getCollection('news', (item) =>
isNewsItemInLocale(item, locale)
);
const firstNewsItem = allNewsItemsInLocale.find(
(item) => !allNewsItemsInLocale.some((otherItem) => isBefore(item, otherItem))
);
if (!firstNewsItem) {
throw new Error('No first news item.');
}
---
<Page title={t(tPage, { key: 'title' })}>
<section>
<h2 set:html={t(tPage, { key: 'sangschaw' })} />
<p set:html={t(tPage, { key: 'sangschaw-para-1' })} />
</section>
<section id="news">
<h2 set:html={t(tPage, { key: 'news' })} />
<NewsIndex headingLevel="h3" newsItems={[firstNewsItem]} />
<Button classNames="grid-span-3 grid-prose-end" href={`/${locale}/news`}>
{t(tPage, { key: 'aw-news' })} ▶
</Button>
</section>
<section id="about">
<h2 set:html={t(tPage, { key: 'about-us' })} />
<p set:html={t(tPage, { key: 'about-us-para-1' })} />
<p set:html={t(tPage, { key: 'about-us-para-2' })} />
<p set:html={t(tPage, { key: 'about-us-para-3' })} />
<h3 set:html={t(tPage, { key: 'meet-the-commattee' })} />
<CommitteeList />
</section>
<section>
<h2 set:html={t(tPage, { key: 'furthsettins' })} />
<p set:html={t(tPage, { key: 'furthsettins-para' })} />
</section>
</Page>
|